home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1638 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: directories listing
  5. Date: Mon, 15 Jan 96 17:52:52 GMT
  6. Organization: none
  7. Message-ID: <821728372snz@genesis.demon.co.uk>
  8. References: <4dckfq$4um@news.ust.hk>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4dckfq$4um@news.ust.hk>
  15.            cs_lcm@ug.cs.ust.hk "Lee Chun Man Raymond" writes:
  16.  
  17. >
  18. >Hi,
  19. >
  20. >        I wrote a C program that needs to print out a listing of  
  21. >sub-directories of current working directory.
  22.  
  23. Peter has answered your question. However:
  24.  
  25. ...
  26.  
  27. >   strcpy(file_path, path_name);
  28. >   strcat(file_path, "\\");
  29. >   strcat(file_path, current_file.name)
  30.                                           ;
  31.  
  32. Don't overlook the powerful function sprintf. You could replace these 3
  33. statements with the simple:
  34.  
  35.     sprintf(file_path, "%s\\%s", path_name, current_file.name);
  36.  
  37. -- 
  38. -----------------------------------------
  39. Lawrence Kirby | fred@genesis.demon.co.uk
  40. Wilts, England | 70734.126@compuserve.com
  41. -----------------------------------------
  42.